@svizzle/utils/[any-object]-[array-object]

Methods

(static) makeAllOccurrencesWith(accessor) → {function}

Source:
Since:
  • 0.5.0
See:

Return a function expecting an array and returning an object of occurrences of all the keys contained in the property reachable with the provided accessor in the items of the provided array

Example
> items = [
  {foo: 1, bar: {a: 1}},
  {foo: 1, bar: {a: 6, b: -1}},
  {foo: 1, bar: {a: 2, b: 0, c: 1}},
  {foo: 1, bar: {c: 4, e: 2}},
]
> makeAllOccurrences = makeAllOccurrencesWith(_.getKey('bar'))
> makeAllOccurrences(items)
{a: 3, b: 2, c: 2, e: 1}
Parameters:
Name Type Description
accessor function

(Any -> Object) the accessor to get the object to inspect

Returns:
  • (Array -> Object) the function to gather the keys occurrencies
Type
function